//
//  ClubSettingController.m
//  PaiQuan
//
//  Created by Mac on 16/7/15.
//  Copyright © 2016年 huigu. All rights reserved.
//

#import "ClubSettingController.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
@interface ClubSettingController ()<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
    UIImagePickerController *_imagePickerController;
}
@property(nonatomic,strong)UIView *coverView;
@property(nonatomic,strong)NSArray *infoArr;
@property(nonatomic,strong)NSArray *specificArr;

@end

@implementation ClubSettingController

- (void)viewDidLoad {
    [super viewDidLoad];
    //创建UIImagePickerController对象
    _imagePickerController = [[UIImagePickerController alloc] init];
    _imagePickerController.delegate = self;
    _imagePickerController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    _imagePickerController.allowsEditing = YES;
    
    self.infoArr = @[@"头像",@"俱乐部",@"地区",@"介绍"];
    self.specificArr = @[@"05_normal",@"贺拉斯",@"温州",@"相对"];
    
    self.titleView.title = @"俱乐部设置";
    [self.titleView.btnBack setImage:PQIMG(@"back") forState:UIControlStateNormal];
    [self.titleView.btnBack setTitle:@"返回" forState:UIControlStateNormal];
    [self.titleView.btnBack setTitleColor:PQ_COLOR_YELLOW forState:UIControlStateNormal];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.infoArr.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *ID =@"id";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID ];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
        cell.textLabel.text = self.infoArr[indexPath.section];
        if (indexPath.section == 0) {
            UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:self.specificArr[indexPath.section]]];
            cell.accessoryView = imageView;
            
        }else{
              cell.detailTextLabel.text = self.specificArr[indexPath.section];
        }
      
        
    }
    
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
//    self.coverView = [[UIView alloc] init];
//    self.coverView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
//    self.coverView.frame = CGRectMake(0, 0, ScreenW, ScreenH);
// 
//    [self.view addSubview:self.coverView];

    
    
        
      if (indexPath.section == 0) {
          UIAlertController *alertView = [UIAlertController alertControllerWithTitle:@"设置头像" message:nil preferredStyle:UIAlertControllerStyleAlert];
          
        
        [alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            _imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
           
            [self presentViewController:_imagePickerController animated:YES completion:nil];
            
        }]];
        [alertView addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            _imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            
            [self presentViewController:_imagePickerController animated:YES completion:nil];
            
        }]];
        [alertView addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            [self.coverView removeFromSuperview];
        }]];
       
          [self presentViewController:alertView animated:YES completion:nil];

          
        
        
        
      } if(indexPath.section == 1){
          UIAlertController *alertView = [UIAlertController alertControllerWithTitle:@"修改昵称" message:@"独一无二的名字，会让俱乐部变得更加特别，请使用中英文数字和下划线，俱乐部名称只能免费修改一次"preferredStyle:UIAlertControllerStyleAlert];
          [alertView addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
              
          }];
          [alertView addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
              [self.coverView removeFromSuperview];

                       }]];
          [alertView addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
              [self.coverView removeFromSuperview];

              
          }]];
          [self presentViewController:alertView animated:YES completion:nil];

          
      }
    if (indexPath.section ==2) {
        UIAlertController *alertView = [UIAlertController alertControllerWithTitle:@"请输入新的地址" message:@"详细的地址会吸引更多的女性玩家"preferredStyle:UIAlertControllerStyleAlert];
        [alertView addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
            
        }];
        [alertView addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [self.coverView removeFromSuperview];
            
        }]];
        [alertView addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [self.coverView removeFromSuperview];
            
            
        }]];
        [self presentViewController:alertView animated:YES completion:nil];
        
    }if (indexPath.section == 3) {
        UIAlertController *alertView = [UIAlertController alertControllerWithTitle:@"请输入新的俱乐部介绍" message:@"详细的地址会吸引更多的会员"preferredStyle:UIAlertControllerStyleAlert];
        [alertView addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
            
        }];
        [alertView addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [self.coverView removeFromSuperview];
            
        }]];
        [alertView addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [self.coverView removeFromSuperview];
            
            
        }]];
        [self presentViewController:alertView animated:YES completion:nil];
        

    }
    
   
    
}
//_imagePickerController的代理方法 在imagePickerController:didFinishPickingMediaWithInfo:代理方法中处理得到的资源，保存本地并上传...
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(nullable NSDictionary<NSString *,id> *)editingInfo {
    NSLog(@"选择完毕----image:%@-----info:%@",image,editingInfo);
    
}


@end
